package com.huatai.exchange.bootup;

import static springfox.documentation.builders.PathSelectors.regex;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.*;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@ComponentScan
@EnableAutoConfiguration
@SpringBootApplication
@ImportResource({ "classpath*:/spring/*.xml" })
@EnableSwagger2
public class SpringHuataiExchangeApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext cac = SpringApplication.run(SpringHuataiExchangeApplication.class, args);
		cac.registerShutdownHook();
	}

	@Bean
	public Docket swaggerSpringMvcPlugin() {
		ApiInfo apiInfo = new ApiInfo("huatai exchange project ", "exchange bootup", null, null, null, null, null);
		ApiSelectorBuilder asb = new Docket(DocumentationType.SWAGGER_2).select();
		asb.paths(regex("/.*"));
		Docket docket = asb.build().apiInfo(apiInfo).useDefaultResponseMessages(false);
		return docket;
	}

}
